'use strict';

/* testData Service */
app.service('testData', ['$window','$filter', function ($window,$filter) {
    this.menu = {
        details: function () {
            var menuTypeNames = ['套餐', "单品"];
            var menuItemNames =  ['牛肉灌汤包xixi','招牌一号灌汤包','招牌一号蒸包','小米粥','花生粥','鲜肉灌汤包','招牌凉菜','牛肉饼'];
            var units = ["份", "个", "杯"];
            var codes = ["001", "002", "003", "004"];
            var itemCodes = ["001","002","003","004","005","006","007","008","009","010","011","012","013","014"];
            var setMealTypeNames = ["主食", "配菜", "调料", "饮料"];
            var setMealItemNames = ["猪排", "羊排", "米饭", "意面", "可乐", "芬达", "面包"];
            return {
                Result: true,
                ResultMsg: "success",
                ResultData: {
                    billInfo:{
                        status:0,
                        billDate:"",
                        billDateTime:"",
                        billGUID:"",
                    },
                    billItemsInfo:_.map(_.range(1,5),function(val){
                           var item = {
                               itemCode:itemCodes[_.random(0,itemCodes.length - 1)],
                               itemName:"",
                               itemStandard:"",
                               itemStandardNo:"",
                               recipes:"",
                               remark:"",
                           };
                           if(_.random(1) == 1){
                               item.mealItems = [];
                           }else {
                               item.mealItems = _.map(_.range(1,4),function(i){
                                   return{
                                       name:"",
                                       code:"",
                                        mealItemList:_.map(_.range(1,3),function(item){
                                            return{
                                                typecode: codes[_.random(0, codes.length - 1)],
                                            }
                                        })
                                   }
                               })
                           };
                           return item;
                    }),
                    menutypes: _.map(_.range(1, 3), function (i) {
                        return {
                            code: _.padStart(i, 3, '0'),
                            name: menuTypeNames[i - 1]
                        }
                    }),
                    menuitems: _.map(_.range(1, 40), function (i) {
                        var typecode = codes[_.random(0, codes.length - 1)];
                        var menuitem = {
                            code: _.padStart(i, 2, '0'),
                            name: menuItemNames[_.random(0, menuItemNames.length - 1)],
                            picpath: "img/wx/reserve/menuitem-default.jpg",
                            typecode: typecode,
                            isCommended:_.random(0,5),
                            recipes: []
                        };
                        if (_.random(1) == 1) {
                            menuitem.standards = _.map(_.range(_.random(1,5)), function (_i) {
                                return {
                                    price: _.range(10, 100, 10)[_.random(_i)],
                                    unit: units[_.random(0, units.length - 1)],
                                    unitNo: _.random(1, 100),
                                    count: 0,
                                    recipes: ["加肉", "加菜", "加饭", "加骨头", "加糖"]
                                }
                            });
                            menuitem.setmeal = {types: [], mealList: []};
                        } else {
                            menuitem.name = menuitem.name + ' 套餐';
                            menuitem.standards = [{
                                price: _.range(10, 100, 10)[_.random(0, 8)],
                                unit: units[_.random(0, units.length - 1)],
                                unitNo: _.random(1, 100),
                                count: 0,
                                recipes: ["加肉", "加菜", "加饭", "加骨头", "加糖"]
                            }];
                            menuitem.setmeal = {
                                types: _.map(_.range(1,4), function (v) {
                                    return {
                                        typeName: setMealTypeNames[v - 1],
                                        code: _.padStart(v, 3, '0'),
                                        max: _.random(1, 3)
                                    }
                                }),
                                mealList: _.map(_.range(1, 12), function (_v) {
                                    return {
                                        name: setMealItemNames[_.random(0, setMealItemNames.length - 1)],
                                        code: _.padStart(_v, 1, '0'),
                                        typecode: codes[_.random(0, codes.length - 1)],
                                        maxCount: 1,
                                        standtards: {
                                            unit: units[_.random(0, units.length - 1)],
                                            price: _.range(10, 100, 10)[_.random(5)],
                                            recipes: ["加肉", "加菜", "加饭", "加骨头", "加糖"],
                                        }
                                    }
                                })
                            };
                        }
                        return menuitem;
                    })
                }
            }
        }
    };
    this.payBill = {
        initPayBillPage:function(){
           var ShopNames =["A店","B店","C店","D店","E店",]
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:{
                    BillDetail:{
                        hasCustomerDetails:true,
                        name:"xp",
                        tel:188188188888,
                        BillDateTime:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd HH:mm:ss'),
                        ReserveTime:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd'),
                        BillGuid:_.random().toString(36).substr(2),
                        BillNo:_.padStart(_.random(5),9,'0'),
                        BillPrice:_.range(10,100,10)[_.random(8)],
                        BillShopName:ShopNames[_.random(0,ShopNames.length-1)],
                        BillItems:_.map(_.range(1,5),function(val){
                            var ItemDcPriceTypes = ["MemberPrice","PostPrice","NormalPrice"];
                            var Items = ['叉烧炒饭', "皮蛋瘦肉粥", "鸡蛋肠", "瘦肉肠", "艇仔粥", "手撕鸡", "白切鸡", "香菇滑鸡"];
                            var Units = ["份", "个", "杯"];
                            return{
                                ItemCode:_.padStart(val,3,'0'),
                                ItemCount:_.random(1,5),
                                ItemDcPrice:_.range(10,100,10)[_.random(3)],
                                ItemDcPriceType:ItemDcPriceTypes[_.random(0,ItemDcPriceTypes.length - 1)],
                                ItemName:Items[_.random(0,Items.length -1)],
                                ItemPrice:_.range(10,100,10)[_.random(3)],
                                ItemStandard:Units[0,Units.length-1],
                                ItemStandardNo:1
                            }
                        })

                    },
                    CardList:_.map(_.range(1,3),function(val){
                        var CardNames = ["青铜会员卡","白银会员卡"];
                        return{
                            CardGUID:_.padStart(val,8,'0'),
                            CardName:CardNames[val-1],
                            CardNo:"A"+ _.padStart(val,4,'0'),
                            Balance:_.range(10,1000,100)[_.random(3)],
                            AvailablePoint:0
                        }
                    }),
                    CashCouponList:_.map(_.range(1,5),function (val) {
                        return{
                            CouponCash:_.random(1,5),
                            CouponCode:_.padStart(val,5,'0'),
                            CouponEndTime:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd HH:mm:ss'),
                            CouponGUID:_.padStart(val,7,'0'),
                            CouponName:_.random(1,5)+'元代金券',
                            CouponStartTime:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd HH:mm:ss'),
                            FullCut:_.random(0,10),
                            UnUseReason:"",
                            Useable:true
                        }
                    }),
                    ObjectCouponList:_.map(_.range(1,5),function (val) {
                        return{
                            CouponCode:_.padStart(val,5,'0'),
                            CouponEndTime:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd HH:mm:ss'),
                            CouponGUID:_.padStart(val,7,'0'),
                            CouponName:_.random(1,5)+'元代物券',
                            CouponStartTime:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd HH:mm:ss'),
                            CouponItemsTag:_.random(0,2),
                            CouponIncludeItems:['aa菜品','bb菜品','cc菜品','dd菜品','ee菜品','ff菜品','xx菜品'],
                            UnUseReason:"",
                            Useable:true
                        }
                    }),
                }
            }
        },
        previewPayResult:function(){
            return{
                Result:true,
                ResultMsg:"success",
                ResultData: {
                    OrderTotalPrice:_.range(10,100,10)[_.random(5)],
                    CardName:"青铜会员卡",
                    CardNo:"A00186",
                    CouponSum:_.range(1,10,1)[_.random(3)],
                    DiscountSum:_.range(1,10,1)[_.random(3)],
                    Odd:"0.02",
                    OrderActualPrice:_.range(10,100,10)[_.random(5)],
                }
                }
        }
    };
    this.address = {
        initData:function(){
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:_.map(_.range(1, 4), function (_num) {
                    return {
                        id: "xxx_xxx_" + _.padStart(_num, 3, '0'),
                        tel: '188167666' + _num,
                        name: '用户' + _num,
                        addressName:'广湾18商务港a座220'+_num
                    };
                })
            }
        }
    };
    this.coupon = {
        initData:function(){
            var couponName = ['1元代金券', '测试代金券'];
            var CouponType = ["CashCoupon", "ObjectCoupon"];
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:_.map(_.range(1, 5), function (i) {
                    return {
                        "code": i,
                        "couponFullCut": "满10元可用",
                        "couponID": "1301bf6a-dc13-43d7-9c33-dc6405f7855c" + i,
                        "endTime": "2018-01-30",
                        "startTime": "2018-01-30",
                        "couponName":couponName[_.random(0, couponName.length - 1)],
                        "couponType": CouponType[_.random(0, CouponType.length - 1)],
                        "couponItemsTag": 0,
                        "couponIncludeItems":[]
                    }
                })
            }
        }
    };
    this.points = {
        details:function(){
            var incomeTypeName = ['门店充值', '会员卡充值'];
            var chargeTypeName = ['门店消费', '会员卡消费'];
            var arrShops = ['A店', 'B店', 'C店', 'D店'];
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:{
                    pointIncome:_.map(_.range(1,5), function (i) {
                        return {
                            Month: i  + '月',
                            Detail: _.map(_.range(1, 5), function (val) {
                                return {
                                    Income:_.range(100,1000,100)[_.random(5)],
                                    IncomeTypeName: incomeTypeName[_.random(0, incomeTypeName.length - 1)],
                                    IncomeTime: "2016-06-06 12:05:00",
                                    IncomeValue:_.range(10,100,10)[_.random(5)]
                                }
                            })
                        }
                    }),
                    pointCharge:_.map(_.range(1, 5), function (i) {
                        return {
                            Month: i + '月',
                            Detail: _.map(_.range(1, 5), function () {
                                return {
                                    charge: _.range(100, 1000, 100)[_.random(5)],
                                    ChargeTypeName: chargeTypeName[_.random(0, chargeTypeName.length - 1)],
                                    ChargeTime: "2016-06-06 12:05:00",
                                    ChargeValue: _.range(10, 100, 10)[_.random(5)]
                                }
                            })
                        }
                    }),
                    chargeDetails:_.map(_.range(5), function (i) {
                        return {
                            "Month": i + 1 + '月',
                            "DetailsOfMonth": _.map(_.range(_.random(1, 5)), function () {
                                return {
                                    "Cost": _.range(100, 2000, 100)[_.random(18)],
                                    "CostTime": "2016-06-06 12:05:00",
                                    "CostTypeName": "微信线上充值",
                                    "StoreName": arrShops[_.random(0, arrShops.length - 1)]
                                };
                            })
                        }
                    }),
                    pointsChargeList:_.map(_.range(1, 6), function (i) {
                        return {
                            pointsChargeName: _.padEnd('积分兑换券', 6, i),
                            effectTime: $filter('date')(new Date().setSeconds(_.random(-999999, 999999)), 'yyyy-MM-dd HH:mm:ss'),
                            limitedTime: $filter('date')(new Date().setSeconds(_.random(-999999, 999999)), 'yyyy-MM-dd HH:mm:ss'),
                        }
                    })
                }
            }
        }
    };
    this.orders = {
        initData:function(){
            var stores = ["北京路店","东湖店","团一大店","区庄店"];
            return{
                Result:true,
                ResultMsg:"success",
                ResultData: _.map(_.range(1, 4), function () {
                    return {
                        storeName: stores[_.random(0, stores.length - 1)],
                        orderTime: $filter('date')(new Date().setSeconds(_.random(-999999, 999999)), 'yyyy-MM-dd HH:mm:ss'),
                        orderTotal: "￥98"
                    }
                })
            }
        }
    };
    this.stores = {
        list:function(){
            var storesName = ['CoCo都可茶饮','许留山','点都德','永盈茶餐厅'];
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:_.map(_.range(1, 5), function (i) {
                    return {
                        name: storesName[_.random(0, storesName.length - 1)],
                        tel: "18816780888",
                        address: "地址地址地址好长好长好长的地址" + i,
                        src:"",
                    }
                })
            }
        }
    };
    this.payResult = {
        initData:function(_params){
            return {
                Result:true,
                ResultMsg:"success",
                ResultData:{
                    status:_.random(0,1),
                    totalPay:_.range(10,100,10)[_.random(4)]
                }
            }
        }
    };
    this.game = {
        initData:function() {
            return {
                productList:_.map(_.range(1,9),function(i){
                    return {

                    }
                })
            }
        }
    };
    this.reserve = {
        initData:function(){
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:{
                    ShopLogo:"",
                    ShopName:"A店",
                    Menus:_.map(_.range(1,4),function(i){
                        var weekDays = ["周一","周二","周三","周四","周五","周六",]
                        return{
                            DateOfMenu:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd'),
                            MenuOfShopGUID:"1cb430df0cc449c990aa399baa0f2b13"+i,
                            TimeEndOfMenu:_.range(12,24,1)[_.random(11)]+":00",
                            TimeStartOfMenu:_.range(0,11,1)[_.random(11)]+":00",
                            WeekOfMenu:weekDays[_.random(5)]
                        }
                    })
                }
            }
        }
    };
    //新data
    this.MemberCenterPage = {
        InitMemberCenterIndexPage:function(){
            var cardNames = ['a级测试卡','b级测试卡']
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:{
                    CardList:_.map(_.range(1,3),function(val){
                        return{
                            CardGiftValue:0,
                            CardID:_.padStart(val,10,"dfjsfs454j"),
                            CardLogo:'img/wx/index/bg-title.jpg',
                            CardName:cardNames[_.random(0,cardNames.length-1)],
                            CardNo:"439894432"+ val,
                            CardPoints:0,
                            CardValue:3000+val
                        }
                    }),
                    CouponCount:_.random(2,5),
                }
            }
        },
        GetCouponsByID:function(){
            var CouponNames =["1元代金券",'2元代金券','3元代金券','4元代金券'];
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:{
                    DataList:_.map(_.range(1,5),function(val){
                        return{
                            CouponCode:_.padStart(val,5,"sgts"),
                            CouponFullCut:2,
                            CouponID:_.padStart(val,14,"sdfkjfkdjsdfdsd"),
                            CouponInCludeItems:"",
                            CouponItemTag:0,
                            CouponMoney:1,
                            CouponName:CouponNames[_.random(0,CouponNames.length - 1)],
                            CouponStatus:"Enable",
                            CouponType:"CashCoupon",
                            EndTime:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd'),
                            StartTime:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd')
                        }
                    }),
                    DataTotal:4
                }
            }
        },
        InitMemberDetailPage:function(){
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:{
                    BirthDay:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd'),
                    Name:"易先生",
                    Phone:"13032638999",
                    Sex:"男"
                }
            }
        },
        GetVerificationCode:function(){},
        GetMemberItemListPage:function(){
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:{
                   DataList: _.map(_.range(1,10),function(val){
                    return{
                        Balance:85744,
                        BillDateTime:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd'),
                        CardValueCost:_.random(-100,100),
                        GiftPoints:0,
                        GiftValueCost:0,
                        IsUnConsume:0,
                        ItemTag:2,
                        ItemTagStr:"会员卡消费"
                    }
                }),
                    DataTotal:9
                }
            }
        },
        RegisterMember:function(){},
        InitStoreValuePage:function(){
            return{
                Result:true,
                ResultMsg:"success",
                ResultData:{
                    CardGiftValue:0,
                    CardNo:"23294822s",
                    CardValue:34902,
                    StoreValueLink:"http://localhost:8089/MMB/MMBPayV3/PayForStoreValue.aspx?showwxpaytitle=1&oid=XIAOPEI&burl=http%3a%2f%2flocalhost%3a3004%2fsrc%2findex.html%23%2fwx%2fstorevalue%3fType%3d1%26CardID%3de1ed9b4aa6a548799fff2de90162729f"
                }
            }
        },

    };
    this.qusetion = {
        initData:function(){
            var types = ['single','double'];
            var groupNames = ['为什么吃那么多?','为什么那么忙?','为什么吃吃吃?','吃吃吃开心吗?'];
            var answers = ['是的','假的','开心','伤心','哈哈哈哈哈'];
                return{
                Result:true,
                ResultMsg:'success',
                ResultData:{
                    questionGroup:_.map(_.range(1,7),function(val){
                        var item = {
                            id:_.padStart(val,3,0),
                            groupName:groupNames[_.random(groupNames.length - 1)]
                        }
                        if(_.random(1) == 1){
                            item.type = types[_.random(types.length-1)];
                            item.answerList = _.map(_.range(1,4),function(v){
                                return{
                                    id:_.padStart(v,2,0),
                                    answerName: answers[_.random(answers.length - 1)]
                                }
                            })
                        }else{
                            item.type = 'sorce';
                        }
                        return item;
                    })
                }
            }
        }
    };
    this.reserve = {
        ordersInitData:function(){
            return {
                Result:true,
                ResultMsg:'success',
                ResultData:{
                    OrderList:_.map(_.range(1,5),function(val){
                        return{
                            orderId:_.padStart(val,3,0),
                            orderName:'订单'+val,
                            reserveTime:$filter('date')(new Date().setSeconds(_.random(-999999,999999)),'yyyy-MM-dd HH:mm:ss'),
                            totalPrice:_.random(50),
                            status:_.random(1),
                            menuItems:_.map(_.range(1,6),function(i){
                                var menuItemNames = ['叉鸡饭','牛腩饭','鱼腩饭','烧鸭饭','原味鱼粉','老火靓汤']
                                return{
                                    code:_.padStart(i,2,0),
                                    name:menuItemNames[_.random(menuItemNames.length -1 )],
                                }
                            })
                        }
                    }),
                }
            }
        },
        addressInitData:function(){
            return{
                Result:true,
                ResultMsg:'success',
                ResultData:{
                    nearbyAddressList:_.map(_.range(1,6),function(val){
                        var restaurants = ['科学大道','大剧院','五羊新城','萝岗万达','天河新天地'];
                        var addressList = ['科学大道193号优拓邦A座一层及二层','广州天河区珠江新城珠江西路一号广州大剧院','广州市越秀区寺右新马路五羊新村','科丰路89号万达广场二楼2001铺','天河客运站旁'];
                        return{
                            id:_.padStart(val,4,0),
                            name:restaurants[val-1],
                            tel:'020-38377713',
                            address:addressList[val-1],
                            distance:_.range(100,600,100)[val-1]+'m',
                        }
                    })
                }

            }

        } ,
        MenuInitData:function(){
            var menuTypeNames = ['套餐', "单品"];
            var menuItemNames = ['叉烧炒饭', "皮蛋瘦肉粥", "鸡蛋肠", "瘦肉肠", "艇仔粥", "手撕鸡", "白切鸡", "香菇滑鸡"];
            var units = ["份", "个", "杯"];
            var codes = ["001", "002"];
            var itemCodes = ["001","002","003","004","005","006","007","008","009","010","011","012","013","014"];
            var setMealTypeNames = ["主食", "配菜", "调料", "饮料"];
            var setMealItemNames = ["猪排", "羊排", "米饭", "意面", "可乐", "芬达", "面包"];
            return{
                Result:true,
                ResultMsg:'success',
                ResultData:{
                    commendMenuData:_.map(_.range(1,8),function(i){
                        var  commendMenuNames = ['牛肉灌汤包xixi','招牌一号灌汤包','招牌一号蒸包','小米粥','花生粥','鲜肉灌汤包','招牌凉菜','牛肉饼'];
                        return{
                            code: _.padStart(i, 2, '0'),
                            name: commendMenuNames[_.random(0, commendMenuNames.length - 1)]+'套餐',
                            picpath: "img/wx/reserve/bg-menuitem.jpg",
                            standards : [{
                                price: _.range(10, 100, 10)[_.random(0, 8)],
                                unit: units[_.random(0, units.length - 1)],
                                unitNo: _.random(1, 100),
                                count: 0,
                                recipes: ["加肉", "加菜", "加饭", "加骨头", "加糖"]
                            }],
                            mealList: _.map(_.range(1, 12), function (_v) {
                                return {
                                    name: setMealItemNames[_.random(0, setMealItemNames.length - 1)],
                                    code: _.padStart(_v, 1, '0'),
                                    typecode: codes[_.random(0, codes.length - 1)],
                                    maxCount: 1,
                                    standtards: {
                                        unit: units[_.random(0, units.length - 1)],
                                        price: _.range(10, 100, 10)[_.random(5)],
                                        recipes: ["加肉", "加菜", "加饭", "加骨头", "加糖"],
                                    }
                                }
                            })
                        }
                    }),
                    menutypes: _.map(_.range(1, 3), function (i) {
                        return {
                            code: _.padStart(i, 3, '0'),
                            name: menuTypeNames[i - 1]
                        }
                    }),
                    menuitems: _.map(_.range(1, 40), function (i) {
                        var typecode = codes[_.random(0, codes.length - 1)];
                        var menuitem = {
                            code: _.padStart(i, 2, '0'),
                            name: menuItemNames[_.random(0, menuItemNames.length - 1)],
                            picpath: "img/wx/order_dishes/menuitem-default.png",
                            typecode: typecode,

                        };
                        if (_.random(1) == 1) {
                            menuitem.standards = _.map(_.range(_.random(1, 4)), function (_i) {
                                return {
                                    price: _.range(10, 100, 10)[_.random(_i)],
                                    unit: units[_.random(0, units.length - 1)],
                                    unitNo: _.random(1, 100),
                                    count: 0,
                                    recipes: ["加肉", "加菜", "加饭", "加骨头", "加糖"]
                                }
                            });
                            menuitem.setmeal = {types: [], mealList: []};
                        } else {
                            menuitem.name = menuitem.name + ' 套餐';
                            menuitem.standards = [{
                                price: _.range(10, 100, 10)[_.random(0, 8)],
                                unit: units[_.random(0, units.length - 1)],
                                unitNo: _.random(1, 100),
                                count: 0,
                                recipes: ["加肉", "加菜", "加饭", "加骨头", "加糖"]
                            }];
                            menuitem.setmeal = {
                                types: _.map(_.range(1,4), function (v) {
                                    return {
                                        typeName: setMealTypeNames[v - 1],
                                        code: _.padStart(v, 3, '0'),
                                        max: _.random(1, 3)
                                    }
                                }),
                                mealList: _.map(_.range(1, 12), function (_v) {
                                    return {
                                        name: setMealItemNames[_.random(0, setMealItemNames.length - 1)],
                                        code: _.padStart(_v, 1, '0'),
                                        typecode: codes[_.random(0, codes.length - 1)],
                                        maxCount: 1,
                                        standtards: {
                                            unit: units[_.random(0, units.length - 1)],
                                            price: _.range(10, 100, 10)[_.random(5)],
                                            recipes: ["加肉", "加菜", "加饭", "加骨头", "加糖"],
                                        }
                                    }
                                })
                            };
                        }
                        return menuitem;
                    })
                }

            }

        }
    }
}]);